% More information see ETData.m
function r = cate(o1, o2)
    % check objects
    if o1 == o2
        error('can not concatenate with itself');
    end

    % determine if o2 is compatible with o1
    if o1.nEddy ~= o2.nEddy || o1.nTemp ~= o2.nTemp
        error('number of channels is not compatible');
    end
    for i = 1 : o1.nEddy
        if ~strcmp(o1.Elabel{i}, o2.Elabel{i})
            error('label of eddy is not compatible');
        end
    end
    for i = 1 : o1.nTemp
        if ~strcmp(o1.Tlabel{i}, o2.Tlabel{i})
            disp([o1.Tlabel{i}, ' ', o2.Tlabel{i}]);
            error('label of temp is not compatible');
        end
    end

    t1 = rem(o1.Time(end), 1440);
    t2 = rem(o2.Time(1), 1440);
    dt = t2 - t1;
    if dt < 0 || dt > 10
        error('end time of o1 and start time of o2 is not compatible')
    end
    t3 = o1.Time(end) - t1;

    % concatenate o1 and o2
    r = ETData;

    r.name   = [o1.name, '+', o2.name];
    r.Time   = [o1.Time; (o2.Time + t3)];
    r.Eddy   = [o1.Eddy; o2.Eddy];
    r.Temp   = [o1.Temp; o2.Temp];
    r.Elabel = o1.Elabel;
    r.Tlabel = o1.Tlabel;
    r.nEddy  = o1.nEddy;
    r.nTemp  = o1.nTemp;
    r.m      = o1.m + o2.m;
end
